package schoolWork.work04.test1;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        double value;
        for (int i = 0; i < 3; i++) {
            try{
                System.out.println("please input a double number");
                value = reader.nextDouble();
                System.out.println("输入正确!");
                break;
            }catch(InputMismatchException e){
                System.out.println("错误地输入了非数字字符，请重新输入");
                System.out.println("你还有"+(2-i)+"次机会");
                reader.next(); //吸收错误的输入
            }
        }

    }
}
